package xj.model.uml;

import static xj.model.uml.UMLModelConstants.ATTR_END;
import static xj.model.uml.UMLModelConstants.ATTR_MESSAGE;
import static xj.model.uml.UMLModelConstants.ATTR_START;
import static xj.model.uml.UMLModelConstants.ATTR_TYPE;

public class UMLMessage extends ConstrainedAssociationElement {

  public enum MessageType {
      Default, 
      Synchorous_Call, 
      Asynchorous_Call, 
      Return, 
      Lost_Massge, 
      Found_Massge, 
      Create_Object, 
      Delete_Object,
  }

  public UMLMessage() {
    this(MessageType.Default, null, null);
  }

  public UMLMessage(MessageType type) {
    this(type, null, null);
  }

  public UMLMessage(MessageType type, MessageNode left, MessageNode right) {
    super(left, right);
    setType(type);
    destructable = false;
    preserved = true;
  }

  public MessageType getType() {
    return type;
  }

  public void setType(MessageType type) {
    this.type = type;
    setAttribute(ATTR_TYPE, type);
  }

  public String getMessage() {
    return message;
  }

  public void setMessage(String message) {
    this.message = message;
    setAttribute(ATTR_MESSAGE, message);
  }

  public int getStart() {
    return start;
  }

  public void setStart(int start) {
    this.start = start;
    setAttribute(ATTR_START, start);
  }

  public int getEnd() {
    return end;
  }

  public void setEnd(int end) {
    this.end = end;
    setAttribute(ATTR_END, end);
  }

  @Override
  public Object clone() throws CloneNotSupportedException {
    UMLMessage t = (UMLMessage) super.clone();
    t.setType(type);
    t.setMessage(message);
    t.setStart(start);
    t.setEnd(end);
    return t;
  }

  protected MessageType type;

  protected String message;

  protected int start, end;

}
